package ui;

import java.awt.EventQueue;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import node.NodeDescriptor;

public class ControllerDiscoveryUi implements ActionListener{

	private DiscoveryUi DiscoveryUi = null;
	
	
	public void start() {
		final ControllerDiscoveryUi ControllerDiscoveryUi = this;
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					DiscoveryUi = new DiscoveryUi();
					DiscoveryUi.getFrame().setVisible(true);
					DiscoveryUi.getBtnSet().addActionListener(ControllerDiscoveryUi);	
					DiscoveryUi.getFieldTimeout().setText(String.valueOf(NodeDescriptor.getInstance().getD_timeout()));
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}
	
	

	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		
		if(!DiscoveryUi.getFieldTimeout().getText().isEmpty())
		{
			NodeDescriptor.getInstance().setD_timeout(Integer.parseInt(DiscoveryUi.getFieldTimeout().getText()));
			System.out.println(NodeDescriptor.getInstance().getD_timeout());
		
		}
		
	}
	
	

}
